
const Sequelize = require("sequelize")
function getConn(mysql) {
	console.log("数据库" + mysql.database)
	const sequelize = new Sequelize(mysql.database, mysql.user, mysql.password, {
		dialect: "mysql",
		port: mysql.port,
		host: mysql.host,
		pool: { // 如果要覆盖用于读取池的选项，可以在此处进行
			max: 20,
			idle: 30000
		},
		logging: true
	})
	return sequelize
}
console.log(process.env.EGG_SERVER_ENV)
var sequelize
/* if (process.env.EGG_SERVER_ENV == "prod") {
	sequelize = getConn({port: 3306, database: "wechat2", user: "bmmysql", password: "nY0RnpK9jF4qPqih", host: "10.13.174.181"})
} else */

if (process.env.EGG_SERVER_ENV == "test") {
	sequelize = getConn({port: 3306, database: "mserver", user: "bmmysql", password: "nY0RnpK9jF4qPqih", host: "10.13.174.181"})
}
else {
	sequelize = getConn({port: 3306, database: "mserver", user: "root", password: "root"})
}
const app = {Sequelize, model: sequelize}

let Application = require("../app/model/application")(app)
let AdminUser = require("../app/model/adminUser")(app)
let ApplicationUser = require("../app/model/applicationUser")(app)
let Module = require("../app/model/module")(app)
let ModuleApplicat = require("../app/model/moduleApplicat")(app)
let UnionUser = require("../app/model/unionUser")(app)
let Ads = require("../app/model/ads")(app)

let AmoPartci = require("../app/model/amoPartci")(app)
let UmPartci = require("../app/model/umPartci")(app)


let AssistData = require("../app/model/game/assistData")(app)
let AdditionProp = require("../app/model/game/additionProp")(app)
let GameUser = require("../app/model/game/gameUser")(app)
let EmpireStore = require("../app/model/game/empireStore")(app)
let UserProp = require("../app/model/game/userProp")(app)
let UserEmpireStore = require("../app/model/game/userEmpireStore")(app)

let GameUserSign = require("../app/model/game/gameUserSign")(app)

let AdCount = require("../app/model/adCount")(app)
module.exports = {
	Application, AdminUser, ApplicationUser, Module, ModuleApplicat, UnionUser, AmoPartci, UmPartci, Ads, Game: {
		AssistData, AdditionProp, GameUser, EmpireStore, UserProp, UserEmpireStore, GameUserSign
	},
	AdCount,
	SQLModel: app.model
}
Object.assign(app.model, module.exports)

require("../app/util/relation")(app)